//
//  WZGAplyFillInformationTwoCell.m
//  ZCJZ
//
//  Created by 潘洪波 on 2020/2/27.
//  Copyright © 2020 jeking. All rights reserved.
//

#import "WZGAplyFillInformationTwoCell.h"
#import <UILabel+Flex.h>
#import <UIImageView+WebCache.h>
@interface WZGAplyFillInformationTwoCell ()

@property (nonatomic, strong) UIImageView *idCardFrontImg ;
@property (nonatomic, strong) UIImageView *idCardBackImg ;

@property (nonatomic, strong) UILabel *firstLab ;
@property (nonatomic, strong) UILabel *secondLab ;

@end


@implementation WZGAplyFillInformationTwoCell

- (instancetype)initWithFlex:(NSString *)flexName reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithFlex:flexName reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.idCardFrontImg setUserInteractionEnabled:YES];
        self.idCardFrontImg.image = [UIImage imageNamed:@"idcard_front"];
        self.idCardFrontImg.tag = 100;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addImgTap:)];
        [self.idCardFrontImg addGestureRecognizer:tap];
        
        [self.idCardBackImg setUserInteractionEnabled:YES];
        self.idCardBackImg.image = [UIImage imageNamed:@"idcard_back"];
        UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addImgTap:)];
        [self.idCardBackImg addGestureRecognizer:tap1];
        self.idCardBackImg.tag = 200;
    }
    return self;
}

- (void)addImgTap:(UITapGestureRecognizer*)tap{
    UIView *view = tap.view;
    if (self.imageTaped) {
        self.imageTaped(view.tag);
    }
}

- (void)setForntImg:(NSString *)forntImg{
    _forntImg = forntImg;
    if (forntImg) {
        [self.idCardFrontImg sd_setImageWithURL:[NSURL URLWithString:forntImg] placeholderImage:[UIImage imageNamed:@"idcard_front"] options:SDWebImageAllowInvalidSSLCertificates];
    }else{
        self.idCardFrontImg.image = [UIImage imageNamed:@"idcard_front"];
    }
}

- (void)setBackImg:(NSString *)backImg{
    _backImg = backImg;
    if (backImg) {
        [self.idCardBackImg sd_setImageWithURL:[NSURL URLWithString:backImg] placeholderImage:[UIImage imageNamed:@"idcard_back"] options:SDWebImageAllowInvalidSSLCertificates];
    }else{
        self.idCardBackImg.image = [UIImage imageNamed:@"idcard_back"];
    }
}

- (void)setHideActionText:(bool)hideActionText{
    if (hideActionText) {
        [self.firstLab setFlexAttrString:@"" name:@"a"];
        [self.firstLab setFlexAttrString:@"" name:@"b"];
        [self.firstLab updateAttributeText];
        [self.secondLab setFlexAttrString:@"" name:@"a"];
        [self.secondLab setFlexAttrString:@"" name:@"b"];
        [self.secondLab updateAttributeText];
        
        self.firstLab.text = @"身份证人像面";
        self.secondLab.text = @"身份证国徽面";
    }else{
        [self.firstLab setFlexAttrString:@"点击上传" name:@"a"];
        [self.firstLab updateAttributeText];
        [self.secondLab setFlexAttrString:@"点击上传" name:@"a"];
        [self.secondLab updateAttributeText];
    }
}

@end
